package controller;


import dao.ChargeDao;
import entity.Charge;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.data.web.HateoasPageableHandlerMethodArgumentResolver;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import service.ChargeService;

import java.util.HashMap;
import java.util.Map;

@Controller
@RequestMapping("/Charge")
@Scope("prototype")
public class ChargeController {
    @Autowired
    private ChargeDao chargeDao;
    @Autowired
    private ChargeService chargeService;

    @RequestMapping("/query")
    @ResponseBody
    public Map<String,Object> query(Charge charge,@RequestParam(value = "pageNumber",defaultValue = "1",required = false) int pageNumber, @RequestParam(value = "pageSize",defaultValue = "5",required = false) int pageSize){
        Map<String,Object> map = new HashMap<String,Object>();
        map.put("total",chargeDao.getCount(charge));
        map.put("rows",chargeService.query(charge,pageSize,pageNumber));
        return map;
    }






}
